package service;

import dao.DisciplineDAO;
import java.util.List;
import model.Discipline;
import model.PersistenceType;
import model.ReturnDTO;

/**
 *
 * @author Moraes
 */
public class DisciplineService {

    public ReturnDTO PersistDiscipline(Discipline pDiscipline, PersistenceType pPersistenceType) {
        DisciplineDAO disciplineDAO = new DisciplineDAO();
        ReturnDTO returnDTO = new ReturnDTO();

        if (pPersistenceType.equals(PersistenceType.INSERT)) {
            try {
                disciplineDAO.Insert(pDiscipline);
                returnDTO.result = true;
            } catch (Exception e) {
                returnDTO.result = false;
                returnDTO.errorMessage = e.getMessage();
            }
        }
        return returnDTO;
    }

    public List<Discipline> getAll() {
        DisciplineDAO disciplineDAO = new DisciplineDAO();
        return disciplineDAO.selectAll();
    }
}
